import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
import Header from './components/Header';
import registerServiceWorker from './registerServiceWorker';

import logger from 'redux-logger'
import { composeWithDevTools } from 'redux-devtools-extension'
import thunk from 'redux-thunk';

import { BrowserRouter as Router } from 'react-router-dom';
import router from './router';

import { createStore, applyMiddleware } from 'redux';

import rootReducer from './reducers'

import { Provider } from 'react-redux'


const store = createStore(
  rootReducer,
  composeWithDevTools(
    applyMiddleware(thunk, logger)
  )
)
ReactDOM.render(
  <Provider store={ store }>
    <Router router={ router }>
      <div>
        <Header />
        { router }
      </div>
    </Router>
  </Provider>,
  document.getElementById('root')
);
registerServiceWorker();

if (module.hot) {
  module.hot.accept('./App', () => {
    ReactDOM.render(<App />, document.getElementById('root'))
  })
}
